<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <h:form id="voyage" styleClass="edit">

        <rich:panel>
            <f:facet name="header">#{voyageHome.managed ? 'Edit' : 'Add'} Voyage</f:facet>




            <s:decorate id="dateDepartField" template="layout/edit.xhtml">
                <ui:define name="label">Date depart</ui:define>
                <rich:calendar id="dateDepart"
                          value="#{voyageHome.instance.dateDepart}" datePattern="MM/dd/yyyy hh:mm a"/>
            </s:decorate>


            <s:decorate id="dateArriveeField" template="layout/edit.xhtml">
                <ui:define name="label">Date arrivee</ui:define>
                <rich:calendar id="dateArrivee"
                          value="#{voyageHome.instance.dateArrivee}" datePattern="MM/dd/yyyy hh:mm a"/>
            </s:decorate>



            <div style="clear:both">
                <span class="required">*</span>
                required fields
            </div>

        </rich:panel>

        <div class="actionButtons">

            <h:commandButton id="save"
                          value="Save"
                         action="#{voyageHome.persist}"
                       disabled="#{!voyageHome.wired}"
                       rendered="#{!voyageHome.managed}"/>

            <h:commandButton id="update"
                          value="Save"
                         action="#{voyageHome.update}"
                       rendered="#{voyageHome.managed}"/>

            <h:commandButton id="delete"
                          value="Delete"
                         action="#{voyageHome.remove}"
                      immediate="true"
                       rendered="#{voyageHome.managed}"/>

            <s:button id="cancelEdit"
                   value="Cancel"
             propagation="end"
                    view="/Voyage.xhtml"
                rendered="#{voyageHome.managed}"/>

            <s:button id="cancelAdd"
                   value="Cancel"
             propagation="end"
                    view="/#{empty voyageFrom ? 'VoyageList' : voyageFrom}.xhtml"
                rendered="#{!voyageHome.managed}"/>

        </div>
    </h:form>

<rich:tabPanel switchType="ajax">

    <rich:tab label="Train *" labelClass="required">
    <div class="association" id="trainParent">

        <h:outputText value="There is no train associated with this voyage."
                   rendered="#{voyageHome.instance.train == null}"/>

        <rich:dataTable var="_train"
                   value="#{voyageHome.instance.train}"
                rendered="#{voyageHome.instance.train != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="trainTable">
            <h:column>
                <f:facet name="header">Idtrain</f:facet>
                <h:outputText value="#{_train.idtrain}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Type</f:facet>
                <h:outputText value="#{_train.type}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Place</f:facet>
                <h:outputText value="#{_train.place}"/>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            <s:button id="#{voyageHome.instance.train != null ? 'changeParenttrain' : 'selectParenttrain'}" value="#{voyageHome.instance.train != null ? 'Change' : 'Select'} train"
                       view="/TrainList.xhtml">
                <f:param name="from" value="VoyageEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>

    <rich:tab label="Arrets">
        <h:form styleClass="association" id="arretsChildren">

            <h:outputText value="There are no arrets associated with this voyage."
                       rendered="#{empty voyageHome.arrets}"/>

            <rich:dataTable value="#{voyageHome.arrets}"
                           var="_arret"
                      rendered="#{not empty voyageHome.arrets}"
                    rowClasses="rvgRowOne,rvgRowTwo"
                            id="arretsTable">
                <rich:column sortBy="#{_arret.id.voyageIdVoyage}">
                    <f:facet name="header">Voyage id voyage</f:facet>
                    <h:outputText value="#{_arret.id.voyageIdVoyage}"/>
                </rich:column>
                <rich:column sortBy="#{_arret.id.gareIdgare}">
                    <f:facet name="header">Gare idgare</f:facet>
                    <h:outputText value="#{_arret.id.gareIdgare}"/>
                </rich:column>
                <rich:column sortBy="#{_arret.heureArrivee}">
                    <f:facet name="header">Heure arrivee</f:facet>
                    <h:outputText value="#{_arret.heureArrivee}">
                        <s:convertDateTime type="both" dateStyle="short"/>
                    </h:outputText>
                </rich:column>
                <rich:column sortBy="#{_arret.heureDepart}">
                    <f:facet name="header">Heure depart</f:facet>
                    <h:outputText value="#{_arret.heureDepart}">
                        <s:convertDateTime type="both" dateStyle="short"/>
                    </h:outputText>
                </rich:column>
            </rich:dataTable>

        </h:form>

        <f:subview rendered="#{voyageHome.managed}" id="arrets">
        <div class="actionButtons">
            <s:button id="addarret"
                   value="Add arret"
                    view="/ArretEdit.xhtml"
             propagation="none">
                 <f:param name="voyageIdVoyage"
                         value="#{voyageHome.instance.idVoyage}"/>
                 <f:param name="arretFrom" value="Voyage"/>
            </s:button>
        </div>
        </f:subview>
    </rich:tab>

    <rich:tab label="Reservations">
        <h:form styleClass="association" id="reservationsChildren">

            <h:outputText value="There are no reservations associated with this voyage."
                       rendered="#{empty voyageHome.reservations}"/>

            <rich:dataTable value="#{voyageHome.reservations}"
                           var="_reservation"
                      rendered="#{not empty voyageHome.reservations}"
                    rowClasses="rvgRowOne,rvgRowTwo"
                            id="reservationsTable">
                <rich:column sortBy="#{_reservation.idreservation}">
                    <f:facet name="header">Idreservation</f:facet>
                    <h:outputText value="#{_reservation.idreservation}"/>
                </rich:column>
                <rich:column sortBy="#{_reservation.dateReservation}">
                    <f:facet name="header">Date reservation</f:facet>
                    <h:outputText value="#{_reservation.dateReservation}">
                        <s:convertDateTime type="both" dateStyle="short"/>
                    </h:outputText>
                </rich:column>
            </rich:dataTable>

        </h:form>

        <f:subview rendered="#{voyageHome.managed}" id="reservations">
        <div class="actionButtons">
            <s:button id="addreservation"
                   value="Add reservation"
                    view="/ReservationEdit.xhtml"
             propagation="none">
                 <f:param name="voyageIdVoyage"
                         value="#{voyageHome.instance.idVoyage}"/>
                 <f:param name="reservationFrom" value="Voyage"/>
            </s:button>
        </div>
        </f:subview>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
